<!--{template /module/admin/view/head}-->
<div id="left_layout">
	<div id="main_content" class="container-fluid">
		<!--{template /module/admin/view/head_nav}-->
		<div class="row-fluid">
			<div class="well widget">
				<div class="widget-header">
					<h3 class="title">{lang poll.index.view.header}</h3>
				</div>
				<div class="widget-content">
					<div class="action-wrapper">
						<div class="pull-left">
							<a href="javascript:void(null);" id="btn_enable_list" class="btn btn-small" {$dispatches[operations][audit]}>{lang admin.operation.enable}</a>
							<a href="javascript:void(null);" id="btn_disable_list" class="btn btn-small" {$dispatches[operations][audit]}>{lang admin.operation.disable}</a>
							<a href="javascript:void(null);" id="btn_delete_list" class="btn btn-small" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
							<a href="{$ADMIN_SCRIPT}/poll/_pub" class="btn btn-small" {$dispatches[operations][add]}>{lang poll.index.view.operation.add}</a>
							<span class="help-inline">{lang poll.index.view.tips}</span>
						</div>
					</div>
					<hr>
					<form id="frm_grid" name="frmGrid" action="{$ADMIN_SCRIPT}/poll&page={$_var[page]}&psize={$_var[psize]}" method="post">
					<table class="table table-hover">
						<thead>
							<tr>
								<th width="20"><input type="checkbox" class="fancy" name="cbxAll"/></th>
								<th width="70">{lang poll.index.view.th.pic}</th>
								<th width="70">{lang poll.index.view.th.no}</th>
					            <th>{lang poll.index.view.th.name}</th>
					            <th width="100">{lang poll.index.view.th.type}</th>
					            <th width="120">{lang poll.index.view.th.date}</th>
					            <th width="120">{lang poll.index.view.th.edit}</th>
					            <th width="50">{lang poll.index.view.th.status}</th>
					            <th width="90">{lang poll.index.view.th.operate}</th>
							</tr>
						</thead>
						<tbody>
							<!--{loop $polls $_loop $poll}-->
							<tr class="item-row">
								<td>
						        	<input type="checkbox" class="fancy" name="cbxItem[]" title="{$poll[TITLE]}" value="{$poll[POLLID]}"/>
		           				</td>
		           				<td>
		           					<a href="{$ADMIN_SCRIPT}/poll/_result&id={$poll[POLLID]}{$search[nextquery]}">
									    <!--{if is_array($poll['FILE02'])}-->
									    <img src="{$poll[FILE02][0]}" data="{$poll[FILE02][4]}" style="width:65px; border:1px solid #ccc;" />
									    <!--{elseif is_array($poll['FILE01'])}-->
									    <img src="{$poll[FILE01][0]}" data="{$poll[FILE01][4]}" style="width:65px; border:1px solid #ccc;" />
									    <!--{else}-->
									    <img src="static/images/no-picture.jpg" width="65" style="width:65px;" />
									    <!--{/if}-->
								    </a>
							    </td>
		           				<td class="f14">{$poll[IDENTITY]}</td>
					            <td>
					            	<p class="thin f14">
										<!--{if $poll['OPTIONS'] > 0}-->
											<a href="{$ADMIN_SCRIPT}/poll/_result&id={$poll[POLLID]}{$search[nextquery]}" class="text-success"><strong>{$poll[TITLE]}</strong></a>
									    <!--{else}-->
									    	<span class="text-error"><strong>{$poll[TITLE]}</strong></span>
									    <!--{/if}-->
								    </p>
								    
								    <p class="text-info thin">
									    [{$poll[OPTIONS]}{lang poll.index.view.td.option}/{$poll[VOTES]}{lang poll.index.view.td.vote}]
									    &nbsp;
									    <a href="javascript:void(null);" data="{$poll[IDENTITY]}" title="{$poll[TITLE]}" class="link-qr"><i class="icon-qrcode"></i>{lang poll.index.view.td.qrcode}</a> 
									    <!--{if $poll['ISAWARD'] > 0}-->
									    <a href="{$ADMIN_SCRIPT}/poll/_award&id={$poll[POLLID]}" title="{$poll[TITLE]}" class="link-gift" target="_blank"><i class="icon-gift"></i>{lang poll.index.view.td.award}</a> 
									    <!--{/if}-->
								    </p>
								    
								    <p class="muted thin">{echo cutstr($poll[SUMMARY], 60);}</p>
					            </td>
					            <td class="f12">
					            	<!--{if $poll['OPTIONTYPE']}-->
					            		{lang poll.index.view.td.type.1}
					            	<!--{else}-->
					            		{lang poll.index.view.td.type.2}
					            	<!--{/if}-->
					            	<br/>
					            	<!--{if $poll['LIMITNUM'] > 0}-->
					            		{lang poll.index.view.td.limit}{$poll[LIMITNUM]}{lang poll.index.view.td.limit.vote}
					            	<!--{else}-->
					            		{lang poll.index.view.td.limit.custom}
					            	<!--{/if}-->
					            	<br/>
					            	<!--{if $poll['GUEST']}-->
					            		{lang poll.index.view.td.guest.1}
					            	<!--{else}-->
					            		{lang poll.index.view.td.guest.2}
					            	<!--{/if}-->
					            </td>
					            <td class="f12">
						            {$poll[BEGINTIME]}<br/>
						            {$poll[ENDTIME]}
					            </td>
					            <td class="f12">{$poll[USERNAME]}<br/>{$poll[EDITTIME]}</td>
					            <td>{$poll[STATUS]}</td>
					            <td>
					            	<a class="btn btn-mini btn-primary" href="{$ADMIN_SCRIPT}/poll/_update&id={$poll[POLLID]}&page={$_var[page]}&psize={$_var[psize]}" {$dispatches[operations][edit]}>{lang admin.operation.edit}</a>
					                <a class="btn btn-mini btn-delete" title="{$poll[TITLE]}" data="{$poll[POLLID]}" href="javascript:void(null);" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
				            	</td>
							</tr>
							<!--{/loop}-->
							<!--{if $count == 0}-->
							<tr>
					            <td colspan="8">
					                * {lang admin.operation.empty}
					            </td>
					        </tr>
					        <!--{/if}-->
						</tbody>
					</table>
					</form>
					
					<hr/>
					
					{$pager}
				</div>
			</div>
		</div>
	</div>
</div>

<script>
$(function(){
	$('.fancy').uniform();
	
	$('#btn_enable_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title') + ' ； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.enable}', message:'<p>{lang poll.index.view.operation.enable.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/poll&do=enable_list&page={$_var[page]}&psize={$_var[psize]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang poll.index.view.operation.empty}'});
	});
	
	$('#btn_disable_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title')  + ' ； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.disable}', message:'<p>{lang poll.index.view.operation.disable.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/poll&do=disable_list&page={$_var[page]}&psize={$_var[psize]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang poll.index.view.operation.empty}'});
	});
	
	$('#btn_delete_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title') +'； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang poll.index.view.operation.delete.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/poll&do=delete_list&page={$_var[page]}&psize={$_var[psize]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang poll.index.view.operation.empty}'});
	});
	
	$("#frm_grid input[name='cbxAll']").click(function(){
		if(this.checked){
			$('#frm_grid .item-row').addClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', true).parent().addClass('checked');
		}else{
			$('#frm_grid .item-row').removeClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', false).parent().removeAttr('class');
		}
	});
	
	$("#frm_grid input[name='cbxItem[]']").click(function(){
		if(this.checked) $(this).parent().parent().parent().parent().addClass('warning');
		else $(this).parent().parent().parent().parent().removeClass('warning');
	});
	
	$('#frm_grid .link-qr').click(function(){
		var href = '<p class="f10">{lang poll.index.view.dialog.link}：{$setting[SiteHost]}mobile.do?ac=poll&id=' + $(this).attr('data') + '</p>';
		$.dialog({width:400, title:'{lang poll.index.view.dialog.qrcode}', message:'<div align="center" style="background:#e3e3e3; padding:30px 0;"><img src="{$ADMIN_SCRIPT}/poll/_qrcode&id=' + $(this).attr('data') + '" width="200" height="200" style="width:200px; height:200px;" border="0"/></div>' + href});
	});
	
	$('#frm_grid .btn-delete').click(function(){
		var pollid = $(this).attr('data');
		var tempHTML = '<p>' + $(this).attr('title') + '； </p>';
		$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang poll.index.view.operation.delete.one}</p>' + tempHTML, callback:function(){
			$('#modal_dialog .btn-primary').click(function(){
				$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/poll&do=delete&id=' + pollid + '&page={$_var[page]}&psize={$_var[psize]}');
				$('#frm_grid').submit();
			});
		}});
	});
});
</script>
<!--{template /module/admin/view/foot}-->